package com.lujianfei.powersearch

import android.app.Activity
import android.app.Application
import android.os.Bundle
import com.lujianfei.powersearch.timer.GlobalTimerManager
import com.lujianfei.powersearch.utils.SystemUtils
import com.orm.SugarContext

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        SystemUtils.setApplicationContext(this)
        SugarContext.init(this)
        registerActivityLifecycleCallbacks(object :ActivityLifecycleCallbacks {
            override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
            }

            override fun onActivityStarted(activity: Activity) {
            }

            override fun onActivityResumed(activity: Activity) {
                GlobalTimerManager.instance.start()
            }

            override fun onActivityPaused(activity: Activity) {
                GlobalTimerManager.instance.end()
            }

            override fun onActivityStopped(activity: Activity) {
            }

            override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
            }

            override fun onActivityDestroyed(activity: Activity) {
            }
        })
    }
}